package com.hhss.qishi.DPtest.designpattern.template;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @Auther: zcc
 * @Date: 19-10-9 15:04
 * @Description:
 */
public class Tea extends FlushingBeverage{

    @Override
    void brewing() {
        System.out.println("steeping the tea.");
    }

    @Override
    void withTrimmings() {
        System.out.println("adding lemon");
    }

    /**
     * 是否要求
     * @return
     */
    @Override
    public boolean isRequired(){
        String requiredStr = getInput();
        if(requiredStr.equals("y")){
            return true;
        }
        return false;
    }

    private String getInput(){
        String answer = null;
        System.out.println("Answer whether ingredients are needed（y/n）？");
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        try {
            answer = in.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        if(answer == null){
            answer = "no";
        }
        return answer;
    }
}
